package hector.tang.controller;

import hector.tang.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;

@Controller
@RequestMapping(path = "/json")
public class JsonController {

    @RequestMapping(path = "/getJson")
    @ResponseBody
    public User getUserJson(){
        User user=new User();
        user.setUname("tom");
        user.setAge(25);
        user.setBirthday(new Date());
        return user;
    }

    @RequestMapping("/check")
    @ResponseBody
    public User check(User user){
        System.out.println("json/check  user请求  "+user.toString());
        User u=new User();
        if(user.getUname().equals("jackson")){
            u.setUname("tom");
            u.setAge(25);
            u.setBirthday(new Date());
        }else {
            u.setUname("jackson");
            u.setAge(0);
            u.setBirthday(new Date());
        }
        return u;
    }
}
